package com.ruoyi.web.controller.system.app;

import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AppStartPage;
import com.ruoyi.system.service.IAppStartPageService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * app启动页设置Controller
 * 
 * @author ruoyi
 * @date 2021-07-25
 */
@Controller
@RequestMapping("/system/page")
public class AppStartPageController extends BaseController
{
    private String prefix = "system/page";

    @Autowired
    private IAppStartPageService appStartPageService;


    /**
     * 查询app启动页设置列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AppStartPage appStartPage)
    {
        startPage();
        List<AppStartPage> list = appStartPageService.selectAppStartPageList(appStartPage);
        return getDataTable(list);
    }

    /**
     * 导出app启动页设置列表
     */
    @Log(title = "app启动页设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AppStartPage appStartPage)
    {
        List<AppStartPage> list = appStartPageService.selectAppStartPageList(appStartPage);
        ExcelUtil<AppStartPage> util = new ExcelUtil<AppStartPage>(AppStartPage.class);
        return util.exportExcel(list, "app启动页设置数据");
    }

    /**
     * 新增保存app启动页设置
     */
    @Log(title = "app启动页设置", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AppStartPage appStartPage)
    {
        appStartPage.setCreateTime(new Date(System.currentTimeMillis()));
        appStartPage.setUpdateTime(new Date(System.currentTimeMillis()));
        return toAjax(appStartPageService.insertAppStartPage(appStartPage));
    }

    /**
     * 修改保存app启动页设置
     */
    @Log(title = "app启动页设置", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AppStartPage appStartPage)
    {
        appStartPage.setUpdateTime(new Date(System.currentTimeMillis()));
        return toAjax(appStartPageService.updateAppStartPage(appStartPage));
    }

    /**
     * 删除app启动页设置
     */
    @Log(title = "app启动页设置", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(appStartPageService.deleteAppStartPageByIds(ids));
    }
}
